package com.jinduplan.planmanager.mvp.model

import com.cxz.kotlin.baselibs.mvp.BaseModel
import com.cxz.kotlin.baselibs.utils.GsonHelper
import com.jinduplan.planmanager.bean.*
import com.jinduplan.planmanager.http.MainApi
import com.jinduplan.planmanager.http.MainRetrofit
import com.jinduplan.planmanager.mvp.contract.MainContract
import com.jinduplan.planmanager.mvp.contract.ReportContract
import io.reactivex.rxjava3.core.Observable

/**
 * @author admin
 * @date 2018/11/20
 * @desc
 */
class ReportModel : BaseModel(), ReportContract.Model {
    override fun getReportList(
        page: String,
        limit: String
    ): Observable<HttpResult<ReportListRecord>> {
        return MainRetrofit.service.reportList(GsonHelper.getRequestBoby(arrayListOf("page","limit"), arrayListOf(page,limit)))
    }

    override fun getReportDetail(id: String): Observable<HttpResult<ReportDetailData>> {
        return MainRetrofit.service.reportDetail(GsonHelper.getRequestBoby(arrayListOf("id"),
            arrayListOf(id)))
    }

    override fun report(
        full_name: String,
        position: String,
        content: String,
        type: String,
        images: Array<String>
    ): Observable<HttpResult<ReportDetailData>> {
        return MainRetrofit.service.report(GsonHelper.getRequestBoby(arrayListOf("full_name","position","content","type","images"),
            arrayListOf(full_name,position,content,type,images)))
    }


    override fun uploadPics(pics: String): Observable<HttpResult<PicUploadSuccess>> {
        return MainRetrofit.service.uploadReportPic(GsonHelper.uploadSinglePart(pics,"images"))
    }


}